package com.zhang.spark_1.spark_core.serialize

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

/**
 * @title:
 * @author: zhang
 * @date: 2021/12/8 09:49 
 */
object Spark01_Serialize {

  def main(args: Array[String]): Unit = {
    //获取spark的连接
    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("operator")
    val sc: SparkContext = new SparkContext(conf)

    val rdd: RDD[Int] = sc.makeRDD(List(1, 2, 3, 4), 2)

    val user = new User()
    rdd.foreach(
      num=> println("age"+(user.age+num))
    )


    sc.stop()
  }

  class User extends Serializable {
    var age:Int = 30;
  }
}
